package com.shop.controller;

import com.shop.pojo.ItemsSpec;
import com.shop.service.ItemsSpecService;
import com.shop.vo.ItemsSpecSaveRequest;
import com.shop.vo.ItemsSpecUpdateRequest;
import com.shop.vo.JSONResponse;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * 商品规格 每一件商品都有不同的规格，不同的规格又有不同的价格和优惠力度，规格表为此设计
 *
 * @author yukangkang
 * @email sunlightcs@gmail.com
 * @date 2020-10-30 13:16:29
 */
@RestController
@RequestMapping("items-spec")
public class ItemsSpecController {

    @Autowired
    private ItemsSpecService itemsSpecService;




    /**
     * 信息
     */
    @GetMapping("/info/{id}")
    @ApiOperation(value = "详情")
    public JSONResponse info(@PathVariable("id") String id){
		ItemsSpec itemsSpec = itemsSpecService.getById(id);
        return JSONResponse.ok(itemsSpec);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation(value = "保存")
    public JSONResponse save(@RequestBody ItemsSpecSaveRequest request){
		itemsSpecService.save(request);
        return JSONResponse.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @ApiOperation(value = "修改")
    public JSONResponse update(@RequestBody ItemsSpecUpdateRequest request){
		itemsSpecService.update(request);
        return JSONResponse.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除")
    public JSONResponse delete(@PathVariable String id){
		itemsSpecService.delete(id);
        return JSONResponse.ok();
    }

}
